import React, {Component} from 'react';
import axios from "axios";
import './AxiosRequest.css'


class AxiosRequest extends Component {

    getStudentData = () => {
        // axios.get('/api/reactPractise/listStudent') 同路径端口可以省略前面一段路径
        axios.get('http://localhost:3000/api/reactPractise/listStudent').then(
            response => {
                console.log('SUCCESS', response.data);
            },
            error => {
                console.log('FAIL', error);
            }
        )
    }

    render() {
        return (
            <div className='axios-request'>
                <button className='btn btn-primary' style={{marginTop:'30px'}} onClick={this.getStudentData}> 按钮点击</button>
            </div>
        );
    }
}

export default AxiosRequest;